using System;
using System.Collections.Generic;
using System.Reflection;
using NFreeMarker.Template;

namespace NFreeMarker.Ext.Beans
{
    /**
     * @author Attila Szegedi
     * @version $Id: $
     */
    class OverloadedFixArgMethod : OverloadedMethod
    {
        protected override void OnAddSignature(MemberInfo member, Type[] argTypes)
        {
        }

        protected override void UpdateSignature(int l)
        {
        }

        protected override void AfterSignatureAdded(int l)
        {
        }

        internal override object GetMemberAndArguments(IList<ITemplateModel> arguments, BeansWrapper w)
        {
            //if (arguments == null)
            //{
            //    // null is treated as empty args
            //    arguments = new List<ITemplateModel>(0).AsReadOnly();
            //}
            //int l = arguments.Count;
            //Type[][] marshalTypes = GetMarshalTypes();
            //if (marshalTypes.Length <= l)
            //{
            //    return NoSuchMethod;
            //}
            //Type[] types = marshalTypes[l];
            //if (types == null)
            //{
            //    return NoSuchMethod;
            //}
            ////assert types.length == l;
            //// Marshal the arguments
            //var args = new object[l];
            //Iterator it = arguments.iterator();
            //for(int i = 0; i < l; ++i)
            //{
            //    object obj = w.Unwrap((ITemplateModel) it.next(), types[i]);
            //    if (obj == BeansWrapper.CAN_NOT_UNWRAP)
            //    {
            //        return NoSuchMethod;
            //    }
            //    args[i] = obj;
            //}
            
            //object objMember = GetMemberForArgs(args, false);
            //if (objMember is MemberInfo)
            //{
            //    var member = (MemberInfo) objMember;
            //    BeansWrapper.CoerceBigDecimals(GetSignature(member), args);
            //    return new MemberAndArguments(member, args);
            //}
            //return objMember; // either NO_SUCH_METHOD or AMBIGUOUS_METHOD

            throw new NotImplementedException();
        }
    }
}